/*
 * rom.c
 *
 *  Created on: Sep 19, 2013
 *      Author: Ken Arok
 */

#include <avr/eeprom.h>
#include "rom.h"


void vReadBlockROM(const void *_start_addr, void *_pbuf, uint32_t _len)
{
	eeprom_read_block(_pbuf, _start_addr, _len);
}


void vWriteBlockROM(void *_start_addr, const void *_pbuf, uint32_t _len)
{
	eeprom_write_block(_pbuf, _start_addr, _len);
}


uint8_t vReadByteROM(const void *_addr)
{
	return eeprom_read_byte((const uint8_t *)_addr);
}

uint16_t vReadWordROM(const void *_addr)
{
	return eeprom_read_word((const uint16_t *)_addr);
}

uint32_t vReadDWordROM(const void *_addr)
{
	return eeprom_read_dword((const uint32_t *)_addr);
}

void vWriteByteROM(const void *_addr, uint8_t _val)
{
	uint8_t *_ptr = (uint8_t *)_addr;

	eeprom_write_byte(_ptr, _val);
}

void vWriteWordROM(const void *_addr, uint16_t _val)
{
	uint16_t *_ptr = (uint16_t *)_addr;

	eeprom_write_word(_ptr, _val);
}

void vWriteDWordROM(const void *_addr, uint32_t _val)
{
	uint32_t *_ptr = (uint32_t *)_addr;

	eeprom_write_dword(_ptr, _val);
}
